package q;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class ch6_33 extends JFrame implements ActionListener {
    @Override
    public void actionPerformed(ActionEvent e){
        if(e.getSource()==menuItem1){
            new B.ch6_22();
        }
    }

    JPanel panel;
    JMenuBar menuBar;
    JMenu menu1;
    JMenu menu2;
    JMenuItem menuItem1;
    JMenuItem menuItem2;
    JMenuItem menuItem3;
    JMenuItem menuItem4;
    public ch6_33() {
        panel = new JPanel();
        menuBar = new JMenuBar();
        menu1 = new JMenu("文件");
        menu2 = new JMenu("编辑");
        menuItem1 = new JMenuItem("新建");
        menuItem2 = new JMenuItem("打开");
        menuItem3 = new JMenuItem("保存");
        menuItem4 = new JMenuItem("退出");
        this.setMenuBar(menuBar);
        menuBar.add(menu1);
        menuBar.add(menu2);
        menu1.add(menuItem1);
        menu1.add(menuItem2);
        menu2.add(menuItem3);
        menu2.add(menuItem4);
        this.setVisible(true);
        this.setSize(500, 500);
    }
    public void setMenuBar(JMenuBar menuBar) {
        this.menuBar = menuBar;
    }
    public static void main(String[] args) {
        new ch6_33();
    }
}
